package com.wms_backend.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.wms_backend.dao.CompanyDao;
import com.wms_backend.entity.Company;
import com.wms_backend.entity.Result;
import com.wms_backend.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private CompanyDao companyDao;


    @Override
    public Result addCompany(JSONObject param) {
        Company company = new Company();
        company.setName(param.getString("name"));
        company.setAddress(param.getString("address"));
        company.setPhone(param.getString("phone"));
        Company r = companyDao.save(company);
        if (r != null) {
            return Result.success();
        } else {
            return Result.error("新增公司失败");
        }

    }
}
